package com.hr.user.servlet;

import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.dsna.util.images.ValidateCode;

public class VerifyCodeServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//ValidateCode vc = new ValidateCode(100,30,6,30);
		ValidateCode vc = new ValidateCode(100,30,4,20);
		String code = vc.getCode();
		System.out.println(code);
		HttpSession session = request.getSession();
		session.setAttribute("VerifyCode", code);
		BufferedImage image = vc.getBuffImg();
		//输出即可
		ImageIO.write(image, "bmp", response.getOutputStream());
	}

}
